﻿using log4net;
using System;
using System.Reflection;
using System.Text;
using System.Web;
using AnyOffice.BIZ;
using AnyOffice.Components;
namespace AnyOffice.module.oc
{
    public partial class read : BasePage
    {

        public string attachmentid;
        public string filename;
        public bool isppt;
        public bool isword;      
        public string menu;
        public string url;
        public string fileType;
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
   

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.attachmentid = (Request.QueryString["attachment_id"] == null) ? "" : Request.QueryString["attachment_id"].ToString();
                this.filename = (Request.QueryString["name"] == null) ? "" : Request.QueryString["name"].ToString();
                if (!AttachmentBiz.Contains(this.attachmentid))
                {
                    Response.Write(base.ShowErrorNoNav("无访问权限"));
                    Response.End();
                }
                else
                {
                    if (this.filename.ToLower().EndsWith(".doc") || this.filename.ToLower().EndsWith(".docx"))
                    {
                        this.isword = true;
                        fileType = "doc";
                    }
                    else
                    {
                        this.isword = false;
                    }
                    if (this.filename.ToLower().EndsWith(".ppt") || this.filename.ToLower().EndsWith(".pptx"))
                    {
                        this.isppt = true;
                        fileType = "ppt";
                    }
                    else
                    {
                        this.isppt = false;
                    }
                    if (this.filename.ToLower().EndsWith(".xls") || this.filename.ToLower().EndsWith(".xlsx"))
                    {
                        this.isppt = true;
                        fileType = "xls";
                    }
                    else
                    {
                        this.isppt = false;
                    }

                    this.url = "readdisk.aspx?attachment_id=" + this.attachmentid + "&name=" + Server.UrlEncode(this.filename);
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<TR class=\"TableHeader\">\n");
                    builder.Append("<TD noWrap align=\"middle\">文件操作</TD>\n");
                    builder.Append("</TR>\n");
                    builder.Append("<TR class=\"TableData\" style=\"CURSOR: hand\" onclick=\"TANGER_OCX_PrintDoc();\">\n");
                    builder.Append("<TD noWrap align=\"middle\">打印</TD>\n");
                    builder.Append("</TR>\n");
                    if (!this.isppt)
                    {
                        builder.Append("<TR class=\"TableHeader\">\n");
                        builder.Append("<TD noWrap align=\"middle\">电子认证</TD>\n");
                        builder.Append("</TR>\n");
                        builder.Append("<TR class=\"TableData\" style=\"CURSOR: hand\" onclick=\"DoCheckSign();\">\n");
                        builder.Append("<TD noWrap align=\"middle\">验证签名及印章</TD>\n");
                        builder.Append("</TR>\n");
                    }
                    this.menu = builder.ToString();
                }
            }
        }

    }
}